from redis import ConnectionPool, Redis


class RedisWrapper:
    def __init__(self):
        self.host = "127.0.0.1"
        self.port = 6379
        self.password = None
        self.redis_max_connections = 20

        self.redis_pool = ConnectionPool(
            host=self.host,
            port=self.port,
            password=self.password,
            max_connections=self.redis_max_connections,
            decode_responses=True,  # 自动解码为字符串
            socket_connect_timeout=5  # 连接超时时间（秒）
        )
        self.redis_client = Redis(connection_pool=self.redis_pool)
